import 'package:flutter_module/model/navi_data_article.dart';
import 'package:flutter_module/model/navi_info.dart';
import 'package:flutter_module/service/api_service.dart';
import 'package:get/get.dart';

class ThirdController extends GetxController {
  final ApiService apiService = Get.find<ApiService>();

  List<NaviInfo>? listInfo = [];
  int index = 0; //一级分类下标
  List<NaviDataArticle>? articles = [];//二级分类集合
  void loadData() async {
    List<NaviInfo>? listInfo = await apiService.getNaviList();
    this.listInfo = listInfo;
    updateArticles(0);
    update();
  }

  void updateArticles(int index){
    if (listInfo?.length != 0) articles = listInfo?[index].articles;
    update();
  }

  void changeIndex(int index){
    this.index = index;
    update();
  }
}
